<template>
  <ContentWrap>
    <template #header>
      <div class="card-header">
        <span class="card-title">通知消息</span>
        <span class="more" @click="routeToMore">更多></span>
      </div>
    </template>
    <div class="card-content">
      <div class="list-item" v-for="(item, index) in dataList" :key="index">
        <div class="list-item-title ellipsis ellipsis-1">
          <span :title="item.msgTitle">{{ item.msgTitle }}</span>
        </div>
        <div class="list-item-date">
          {{ formatDate(item.createTime, 'YYYY-MM-DD') }}
        </div>
      </div>
    </div>
  </ContentWrap>
</template>

<script lang="ts" setup>
import { formatDate } from '@/utils/formatTime'
import { MessageApi, MessageVO } from '@/api/dr/message'
const { push } = useRouter() // 路由
const queryParams = reactive({
  pageNo: 1,
  pageSize: 5,
})
const dataList = ref<MessageVO[]>([])

/** 查询列表 */
const getList = async () => {
  try {
    const data = await MessageApi.getMessagePage(queryParams)
    dataList.value = data.list
  } finally {
  }
}
/** 更多 */
const routeToMore = () => {
  push({name: 'Message'})
}
onMounted(() => {
  getList()
})
</script>

<style lang="scss" scoped>
.card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .card-title {
    font-weight: bold;
    line-height: 32px;
  }
  .more {
    font-size: 14px;
    cursor: pointer;
  }
  :deep(.el-tabs__header) {
    margin: 0;
  }
}
.card-content {
  padding: 0 10px;
  height: 216px;
}
.list-item {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--el-card-border-color);
  cursor: pointer;
  &:last-child {
    border-bottom: 0;
  }
  .list-item-title {
    width: 0;
    flex: 1;
  }
}
:deep(.el-card__header) {
  padding: 10px;
}
</style>
